#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define D long double
#define N 500005
int fa[N];
int getf(int x){
	if(x==fa[x])	return x;
	return (fa[x]=getf(fa[x]));
}
int tong[N],to[N];
signed main(){
	freopen("destory.in","r",stdin);
	freopen("destory.out","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m,q;cin>>n>>m>>q;
	for(int i=1;i<=n;i++)	fa[i]=i;
	for(int i=1;i<=m;i++){
		int x,y;cin>>x>>y;x=getf(x);y=getf(y);fa[x]=y;
	}
	for(int i=1;i<=n;i++)	to[i]=getf(i);
	while(q--){
		for(int i=1;i<=n;i++)	tong[i]=0;
		int cnt=0,cnt1=0,mn=1e9;
		int L,R;cin>>L>>R;
		for(int i=L;i<=R;i++)	cnt+=(++tong[to[i]]==1);
		for(int i=L;i<=R;i++)	tong[to[i]]=0;
		int l=L,r=L;cnt1++;tong[to[l]]=1;
		while(l<=R){
			while(r<R&&(cnt1<cnt)){
				r++;cnt1+=(++tong[to[r]]==1);
			}
			if(cnt1>=cnt)	mn=min(mn,r-l+1);
			cnt1-=(--tong[to[l]]==0);l++;
		}
		cout<<mn<<"\n";
	}
	return 0;
}
/*
5 2 5
2 2
4 1
1 1
1 1
2 5
4 5
3 5
*/
